Skip to content

fix(studio): a sealed scale resize lands where it was dropped - #8301

Merged
miguel-heygen merged 26 commits into
mainfrom
fix/sealed-scale-resize-drop
Nov 22, 2026
Merged

miguel-heygen merged 26 commits into
mainfrom
fix/sealed-scale-resize-drop

Conversation

@miguel-heygen

@miguel-heygen miguel-heygen commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Stacked on #8263; retargets main when it merges.

What

In a sealed preview (Studio cannot script the frame), resizing a layer whose GSAP animation scales it now leaves the box where it was dropped. Before, the box landed 40 to 54 px away from the drop, and stayed there after a reload. An unsealed preview already landed it on the drop point.

The sealed preview is off by default until the sealed-by-default change (#7846) lands, so nothing changes for anyone before then.

Why

A scale resize scales the box about its centre, not about the dragged corner. So after saving the scale, Studio measures where the scaled box renders and moves its position onto the point where it was dropped. That step drew on and measured the frame's own element (iframe.contentDocument), which a sealed preview does not expose. So it skipped:

  • the position was never corrected;
  • the resize reported that it had not handled the drag's offset, so the offset was saved again as a second move.

How

The finalize step does the same thing on a sealed frame, over the requests the frame's port already serves (no new request):

  • the drop point is the frame's measure (geometry) of the element while the drag's draft is still drawn;
  • the draft is cleared (draft), the committed scale and the pre-gesture position are drawn (gsap-set), and the frame measures the box again;
  • the correction moves the box onto the drop point (gsap-set) and is saved through the same position write as an unsealed resize. The resize reports that it handled the drag's offset, so no second move is saved.

previewDraftsSent waits until the draft queue's sends are answered, so the measures see the drafts already drawn. The live path is unchanged; it moves into correctOnElement beside the new correctOnFrame.

Test plan

gsapResizeDropPoint.test.ts, "lands on the drop point in a sealed preview, measured by the frame, with no second move": a sealed frame served by the real runtime agent, with the drag's draft drawn over the port. The resize reports that it handled the drag's offset; the saved scale and position render the box on the drop point, and so does the frame.

fails without the fix:

  • with no frame finalize, "lands on the drop point in a sealed preview, measured by the frame, with no second move" fails: the resize does not report the drag's offset as handled.

Run on Linux at this head: the drop-point tests pass three runs in a row (13); Studio's hooks, components/editor, webmcp and player tests (6690) pass; Studio tsc no errors; format clean; fallow audit passes.

Bench

Edit-accuracy bench, move and resize drags of layers GSAP animates (fromto, keys, scale, size) at r0, root, 100% zoom (24 per run). Compared at #8263's head before its main merge (5626b44) and at this change on top of it:

preview accurate resize-scale drop (after / mid / on) failing cases
sealed, #8263 17 40.1 / 53.5 / 48.1 px 7
sealed, this change 21 0.1 / 0.2 / 0.2 px 5
unsealed, #8263 24 0.1 / 0.2 / 0.2 px 1 (smooth only)
unsealed, this change 24 0.1 / 0.2 / 0.2 px 3 (smooth only)

The sealed scale resizes now land where unsealed ones do. Of the 5 sealed failures left, 3 are keys resizes, which #8288 fixed on main; #8263's head now has main merged. The other 2 fail smooth only. smooth (frame pacing) is reported and not gated.

Before

Sealed preview at #8263, the bench's scale layer at 1 s, after a corner drag that grew it. The scale is saved (1.54), but the box sits up and to the left of where it was dropped (53 px at this playhead).

before: the scaled box sits away from where it was dropped

After

The same drag at this change: the box sits where it was dropped, 0.2 px off.

after: the scaled box sits on the drop point

A sealed preview's selection is a stand-in that is never in the page, so the nudge's check that the element is still
there refused every key and nothing moved. It now uses the same check the selection publisher uses, which keeps a
sealed selection until it is replaced.
…d saves where it was drawn

A sealed preview's selected element is a stand-in with no animation or translate of its own, so a nudge guessed both from an empty page: it wrote a plain translate over the stylesheet's and the element landed elsewhere after a reload. The nudge now waits for the frame's gesture-start read, the one a press uses, and keys pressed meanwhile join the burst.
…not twice as far

When a move ends, the sealed frame kept the translate the gesture drew. A move on GSAP's route saves the new position as GSAP's x and y, so the layer then showed the move twice until the frame loaded again. The frame now drops the drawn translate for those moves; a move saved as a plain translate still keeps it.
# Conflicts:
#	packages/studio/src/components/editor/previewGestureStartRead.ts
# Conflicts:
#	packages/studio/src/hooks/gsapResizeIntercept.test.ts
Base automatically changed from fix/studio-sealed-nudge to main November 22, 2026 05:59
@github-actions

github-actions Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Edit accuracy: accurate 271 (base branch 271), smooth 74 of those

The gate passes.
Smoothness is reported in the artifact, not gated. A case fails only if it fails 2 of 3 runs.

Quarantined, measured but not gated (0)

@vanceingalls vanceingalls left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved at c5d657d, CI green. #8263 is merged, so this now targets main.

  • Sealed finalize: it mirrors the live one over requests the port already serves. The drop point is the frame's geometry with the draft still drawn. Then it clears the draft, gsap-set draws the committed scale at the pre-gesture position, re-measures, and gsap-set writes the correction. The position write is the unsealed path's, and reporting the drag offset as handled removes the second move.
  • Live path: it moves into correctOnElement unchanged, including the same-task correction so no frame shows the box off the drop point.
  • previewDraftsSent can't hang: resolvers flush when send finds an empty queue, which .finally always reaches, and the port request has its own timeout. A pending sendsAtTaskEnd microtask also lands there.
  • Flag-off: sealed previews are off until #7846, so this is inert for everyone today.
  • Tests: the "fails without the fix" test uses the real runtime agent over the port. The bench takes sealed scale-resize drops from 40–54 px to 0.1–0.2 px, matching unsealed.

Non-blocking: on a sealed frame readGsapPositionFromIframe returns null (no contentDocument), so preGesture passes {0,0} and the base comes from the gesture stamp alone. The bench says that's right. A comment at preGesture saying the sealed base comes from the stamp would save the next reader the same trace, and the scale-finalize log's gsapPos will read 0,0 there.

@miguel-heygen
miguel-heygen added this pull request to the merge queue Nov 22, 2026
Merged via the queue into main with commit 513dcce Nov 22, 2026
79 checks passed
@miguel-heygen
miguel-heygen deleted the fix/sealed-scale-resize-drop branch November 22, 2026 23:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants